package com.community.comsys.service.impl;

import java.util.List;
import com.community.common.utils.DateUtils;
import com.community.comsys.domain.vo.HouseVoCommunity;
import com.community.comsys.domain.vo.HouseVoStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.community.comsys.mapper.HouseMapper;
import com.community.comsys.domain.House;
import com.community.comsys.service.IHouseService;

/**
 * 房屋管理Service业务层处理
 * 
 * @author 潇东
 * @date 2025-10-27
 */
@Service
public class HouseServiceImpl implements IHouseService 
{
    @Autowired
    private HouseMapper houseMapper;

    /**
     * 查询房屋管理
     * 
     * @param houseId 房屋管理主键
     * @return 房屋管理
     */
    @Override
    public House selectHouseByHouseId(Long houseId)
    {
        return houseMapper.selectHouseByHouseId(houseId);
    }

    /**
     * 查询房屋管理列表
     * 
     * @param house 房屋管理
     * @return 房屋管理
     */
    @Override
    public List<House> selectHouseList(House house)
    {
        return houseMapper.selectHouseList(house);
    }

    /**
     * 新增房屋管理
     * 
     * @param house 房屋管理
     * @return 结果
     */
    @Override
    public int insertHouse(House house)
    {
        house.setCreateTime(DateUtils.getNowDate());
        return houseMapper.insertHouse(house);
    }

    /**
     * 修改房屋管理
     * 
     * @param house 房屋管理
     * @return 结果
     */
    @Override
    public int updateHouse(House house)
    {
        house.setUpdateTime(DateUtils.getNowDate());
        return houseMapper.updateHouse(house);
    }

    /**
     * 批量删除房屋管理
     * 
     * @param houseIds 需要删除的房屋管理主键
     * @return 结果
     */
    @Override
    public int deleteHouseByHouseIds(Long[] houseIds)
    {
        return houseMapper.deleteHouseByHouseIds(houseIds);
    }

    /**
     * 删除房屋管理信息
     * 
     * @param houseId 房屋管理主键
     * @return 结果
     */
    @Override
    public int deleteHouseByHouseId(Long houseId)
    {
        return houseMapper.deleteHouseByHouseId(houseId);
    }

    /**
     * 导入房屋列表
     * @param houseList
     * @return
     */
    @Override
    public int importHouseList(List<House> houseList) {
        houseList.stream().forEach(house -> {
            house.setCreateTime(DateUtils.getNowDate());
            houseMapper.insertHouse(house);
        });
        return houseList.size();
    }

    @Override
    public Long count() {
        return houseMapper.count();
    }

    @Override
    public List<HouseVoCommunity> groupByCommunity() {
        List<HouseVoCommunity> communities = houseMapper.groupByCommunity();
        return communities;
    }

    @Override
    public List<HouseVoStatus> groupByStatus() {
        return houseMapper.groupByStatus();
    }
}
